﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO;
using DAO;
using System.Data;
namespace BUS
{
    public class BanBUS
    {
        public static List<BanDTO> Listbanan(int makv)
        {
            DataTable dt = BanDAO.Danhsachban(makv);
            List <BanDTO> lstban= null;
            if (dt != null)
            {
                lstban = new List<BanDTO>();
                foreach (DataRow dr in dt.Rows)
                {
                    BanDTO ban = new BanDTO();
                    ban.Maban = int.Parse(dr["MABAN"].ToString());
                    ban.Makv = int.Parse(dr["MAKV"].ToString());
                    ban.Succhua = int.Parse(dr["SUCCHUA"].ToString());
                    ban.Trangthai = int.Parse(dr["TINHTRANG"].ToString());
                    lstban.Add(ban);
                }
            }
            return lstban;
        }
        public static bool SetTrangThai(int maban, int status)
        {
            int kt = BanDAO.SetTrangThai(maban, status);
            if (kt > 0)
                return true;
            return false;
        }
        public static bool Update(int maban, int sl, int kv, int trangthai)
        {
            int kt = BanDAO.Update(maban, sl, kv, trangthai);
            if (kt > 0)
                return true;
            return false;

        }
        public static bool Themban(BanDTO ban)
        {
            int kt = BanDAO.Themban(ban);
            if (kt > 0)
                return true;
            return false;
        }
        public static bool Xoaban(BanDTO ban)
        {
            int kt = BanDAO.Xoaban(ban);
            if (kt > 0)
                return true;
            return false;
        }
    }
}
